import { getOrganizationList, getUnitList } from "@/commonData";
import { caseTypeList, progressTypeList } from "@/commonData/dict";
import { FormOptions } from "@/components/SmForm/src/types/types";
import { searchOptionsResolve } from "@/components/SmForm/src/utils";

export const useSearchForm = (handleQuery: any, queryParams: any) => {
  // 1-报案号-field1
  // 2-车牌号-field2
  // 3-车架号-field3
  // 4-被统筹人
  // 5-查勘员
  // 6-案件状态-下拉
  // 7-承统机构-下拉
  // 8-统筹单位-下拉
  // 9-出险时间
  // 10-进展状态
  const organizationList = getOrganizationList();
  const unitList = getUnitList();
  const searchFormOptions = ref<Array<FormOptions>>([
    {
      type: "input",
      label: "报案号",
      prop: "field1",
      placeholder: "报案号",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "车牌号",
      prop: "field2",
      placeholder: "车牌号",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "车架号",
      prop: "field3",
      placeholder: "车架号",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "被统筹人",
      prop: "field4",
      placeholder: "被统筹人",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "查勘员",
      prop: "field5",
      placeholder: "查勘员",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "select",
      placeholder: "案件状态",
      prop: "field6",
      label: "案件状态",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: caseTypeList,
    },
    {
      requiredFlag: true,
      type: "tree-select",
      placeholder: "归属机构",
      prop: "orgId",
      label: "归属机构",
      attrs: {
        filterable: true,
        clearable: true,
        // data: mockTreeList,
        data: organizationList,
        // props: defaultProps,
        "check-strictly": true,
        // "node-key": "id",
      },
    },
    {
      type: "select",
      placeholder: "统筹单位",
      label: "统筹单位",
      prop: "deptId",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: unitList,
    },
    {
      type: "date-picker",
      placeholder: "出险时间",
      prop: "field6",
      label: "出险时间",
      attrs: {
        clearable: true,
        type: "daterange",
        "range-separator": "~",
        editable: false,
        "value-format": "YYYY-MM-DD",
        "start-placeholder": "开始日期",
        "end-placeholder": "结束日期",
      },
    },
    {
      type: "select",
      placeholder: "进展状态",
      label: "进展状态",
      prop: "fieild11",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: progressTypeList,
    },

    // caseTypeList

    // <el-date-picker
    //   v-model="queryParams.createTime"
    //   :editable="false"
    //   type="daterange"
    //   range-separator="~"
    //   start-placeholder="开始时间"
    //   end-placeholder="截止时间"
    //   value-format="YYYY-MM-DD"
  ]);

  searchOptionsResolve(searchFormOptions, handleQuery);

  const getSearchFormData = () => {
    return queryParams;
  };
  return {
    searchFormOptions,
    getSearchFormData,
  };
};
